perm filename PUI1S.PUI[206,JMC] blob sn#005349 filedate 1971-11-24 generic text, type T, neo UTF8
1⎇                     SYNTAX DIRECTED COMPUTATION
2⎇        It⎇ is⎇ often⎇ more⎇ convenient⎇ to⎇ describe⎇ certain⎇ kinds⎇ of
3⎇computation⎇ with⎇ symbolic⎇ expressions⎇ by⎇ "syntax⎇ transformations"
4⎇than⎇ by⎇ recursive⎇ LISP⎇ functions.⎇  For⎇ example,⎇ consider⎇ the
5⎇simplification⎇ of⎇ expressions⎇ in⎇ a⎇ binary⎇  PLUS⎇  and⎇  TIMES⎇  where
6⎇the⎇ number⎇  0⎇  is⎇ to⎇ be⎇ eliminated⎇ from⎇ sums,⎇ the⎇ number⎇  1⎇  is⎇ to⎇ be
7⎇eliminated⎇ from⎇ products,⎇ products⎇ containing⎇  0⎇  are⎇ to⎇ be⎇ replaced
8⎇by⎇  0,⎇ and⎇ sums⎇ and⎇ products⎇ of⎇ one⎇ element⎇ are⎇ to⎇ be⎇ replaced⎇ by
9⎇that⎇ element.⎇  This⎇ may⎇ be⎇ accomplished⎇ by⎇ the⎇ function⎇  simplifya
10⎇defined⎇ by
11⎇        simplifya e ← ␈_if at␈≡ e ␈_then␈≡ e
12⎇                        ␈_else␈≡ {simplifya ␈_ad␈≡ e,simplifya ␈_add␈≡ e}
13⎇                        [λwz. ␈_if a␈≡ e ␈_eq␈≡ PLUS ␈_then␈≡
14⎇                                [␈_if␈≡ w = 0 ␈_then␈≡ z
15⎇                                ␈_else if␈≡ z = 0 ␈_then␈≡ w
16⎇                                ␈_else <PLUS w z>]
17⎇                                ␈_else if␈≡ w = 0 ∨ z = 0 ␈_then␈≡ 0
18⎇                                ␈_else if␈≡ w = 1 ␈_then␈≡ z
19⎇                                ␈_else if␈≡ z = 1 ␈_then␈≡ w
20⎇                                ␈_else␈≡ <TIMES w z>.